package loan.calc.service.loan.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import loan.calc.domain.LoanRateSegmentDO;
import loan.calc.dto.LoanRateSegmentDTO;
import loan.calc.mapper.LoanRateSegmentMapper;
import loan.calc.service.loan.LoanRateSegmentService;
import loan.calc.util.POJOConverter;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class LoanRateSegmentServiceImpl extends ServiceImpl<LoanRateSegmentMapper, LoanRateSegmentDO> implements LoanRateSegmentService {


    @Override
    public List<LoanRateSegmentDTO> getLoanRateSegmentList(Long loanId) {
        return lambdaQuery().eq(LoanRateSegmentDO::getLoanId, loanId).list()
                .stream().map(domain -> POJOConverter.convert(LoanRateSegmentDTO.class, domain))
                .collect(Collectors.toList());
    }
}
